properties { 
  $base_dir = resolve-path .
  $build_dir = "$base_dir\build"
  $packageinfo_dir = "$base_dir\packaging"
  $40_build_dir = "$build_dir\4.0\"
  $lib_dir = "$base_dir\lib\"
  $release_dir = "$base_dir\Release.all"
  $sln_file = "$base_dir\GPU.sln"
  #$version = Get-Version-From-Git-Tag
  $tools_dir = "$base_dir\tools"
  $config = "Release"
  $run_tests = $true
}

$framework = '4.0'

include .\psake_ext.ps1
	
task default -depends Compile

task Clean {
  remove-item -force -recurse $build_dir -ErrorAction SilentlyContinue
  remove-item -force -recurse $release_dir -ErrorAction SilentlyContinue
}

task Init -depends Clean {
	new-item $release_dir -itemType directory 
	new-item $build_dir -itemType directory 
}

task Compile -depends Init {
  msbuild $sln_file /p:"OutDir=$40_build_dir;Configuration=$config;LibDir=$lib_dir"
}

task Test -depends Compile -precondition { return $run_tests }{
  $old = pwd
  cd $build_dir
  & $tools_dir\xUnit\xunit.console.clr4.exe "$40_build_dir\Rhino.ServiceBus.Tests.dll" /noshadow
  cd $old		
}

task Release -depends Compile, Test {

}

task Package -depends Release {
  $spec_files = @(Get-ChildItem $packageinfo_dir)
  foreach ($spec in $spec_files)
  {
    & $tools_dir\NuGet.exe pack $spec.FullName -o $release_dir -Version $version -Symbols -BasePath $base_dir
  }
}
